package com.only4play.productcenter.infrastructure.constants;

import com.only4play.common.constants.BaseEnum;

import java.util.Optional;

/**
 * 10 20 001 前两位 产品中心代表一个部门 ，一个领域 job 哪个应用  约定大于配置
 *
 */
public enum ProductErrorCodeEnum implements BaseEnum<ProductErrorCodeEnum> {

  PRODUCT_NAME_EMPTY(1001001, "产品名称不能为空"),
  GOODS_HAS_IN(1001002, "商品已入库"),
  GOODS_HAS_OUT(1001002, "商品已出库"),

  ;

  ProductErrorCodeEnum(Integer code, String name) {
    this.code = code;
    this.name = name;
  }

  private Integer code;
  private String name;

  @Override
  public Integer getCode() {
    return this.code;
  }

  @Override
  public String getName() {
    return this.name;
  }

  public static Optional<ProductErrorCodeEnum> of(Integer code) {
    return Optional.ofNullable(BaseEnum.parseByCode(ProductErrorCodeEnum.class, code));
  }

}
